<?php

namespace app\api\controller\v1;

use app\api\controller\BaseController;
use app\api\validate\IDMustBePositiveInt;
use app\api\service\Pay as PayService;
use app\api\service\WxNotify;

class Pay extends BaseController{

    protected $beforeActionList = [
                    'checkExclusiveScope'=>['only'=>'placeOrder']
                                ];

    public function getPreOrder($id=''){
        (new IDMustBePositiveInt())->goCheck();
        $pay = new PayService($id);
	    return $pay->pay();
    }

    public function receiveNotify(){
    	// 通知频率 15/15/30/180/1800/1800/1800/1800/3600  9次
    	// 1.检查库存量，超卖
    	// 2.更新这个订单的status状态
    	// 3.减库存
    	// 如果成功处理，我们返回微信成功处理的信息；否则，返回没有成功处理
    	// 特点：post，xml格式，url不能加'?param=……'(不会携带参数)
    	$notify = new WxNotify();
    	$notify->Handle();

    	// $xmlData = file_get_contents('php://input');
		// $result = curl_post_raw('http:/zerg.cn/api/v1/pay/re_notify?XDEBUG_SESSION_START=13133',
		// $xmlData);
		// return $result;
		// Log::error($xmlData);

    }
}

?>
